package com.yunyao.common.constant.enums;

import lombok.Getter;

/**
 * 项目、供货订单对账状态
 * @author chenyejian
 * @date 2024-07-21
 */
@Getter
public enum ReconciliationStatus {
    /**
     * 未对账
     */
    UNRECONCILED("0", "未对账"),
    /**
     * 对账中
     */
    RECONCILIATION_ING("1", "对账中"),
    /**
     * 已对账
     */
    RECONCILED("2", "已对账"),
    /**
     * 部分对账
     */
    PARTIALLY_RECONCILED("3", "部分对账"),
    /**
     * 云采已确认
     */
    YUNCAI_CONFIRMED("4", "云采已确认");

    private final String type;
    private final String description;

    ReconciliationStatus(String type, String description) {
        this.type = type;
        this.description = description;
    }

    /**
     * 可以根据 type 获取枚举实例
     */
    public static String getDescriptionByType(String type) {
        for (ReconciliationStatus status : ReconciliationStatus.values()) {
            if (type.equalsIgnoreCase(status.getType())) {
                return status.getDescription();
            }
        }
        return type;
    }

    /**
     * 可以根据 description 获取枚举实例
     */
    public static String getTypeByDesc(String description) {
        for (ReconciliationStatus status : ReconciliationStatus.values()) {
            if (description.equalsIgnoreCase(status.getDescription())) {
                return status.getType();
            }
        }
        return description;
    }
}
